const ajaxQuery = (url) => {
    return new Promise((resolve, reject) => {
      const http = new XMLHttpRequest();
      http.open("GET", url);
      http.responseType = "json";
      http.onload = function () {
        setTimeout(() => {
          if (this.status === 200) {
            resolve(this.response);
          } else {
            reject(new Error(this.statusText));
          }
        }, 2000);
      };
      http.send();
    });

};

//前端注册到windows，node注册到process上
window.addEventListener("unhandledrejection",(event)=>{
  const {reason,promise} = event;
  console.log("unhandledrejection",reason,promise);//reason错误原因，promise失败的promise
  event.preventDefault();
}),

//不捕获异常时，全局捕获，
ajaxQuery("/xxxx")
  .then((result) => {
    console.log(result);
    return ajaxQuery("/03-test/data2.json");
  })

ajaxQuery("/03-test/data.json")
  .then((result) => {
    console.log(result);
    return ajaxQuery("/03-test/data2.json");
  })
  .then((res) => {
    console.log(res);
  }).catch((err)=>{
    console.log(err);
  });
console.log("哈哈哈e");
